#include "../common/config.h"
#include <boost/lexical_cast.hpp>
#include <Wt/WContainerWidget>
#include <Wt/WMenu>
#include <Wt/WStackedWidget>
#include <Wt/WText>
#include "../common/logmanager.h"
#include "../httpproxy/httpproxy.h"
#include "../httpproxy/httpsession.h"
#include "WebUI.h"
#include "ConfigPage.h"
#include "StatusPage.h"

using namespace std;
using namespace log4cxx;
using namespace Wt;

WebUI::WebUI(const WEnvironment& env) : WApplication(env)
{
	HTTPProxy& proxy = HTTPProxy::getInstance();
	
	setTitle("XRelayer Management");

	WStackedWidget *contents = new WStackedWidget();

	m_menu = new WMenu(contents, Horizontal, root());
	m_config_page = new ConfigPage();
	m_status_page = new StatusPage();

	//m_tab_container->currentChanged.connect(SLOT(this, WebUI::tabChanged));

	m_menu->addItem("Config", m_config_page);
	m_menu->addItem("Status", m_status_page);

	root()->addWidget(contents);

	
}

void WebUI::tabChanged(int index)
{
	LoggerPtr de = Logger::getLogger("debugger");

	LOG4CXX_DEBUG(de, "test");
	
	switch (index)
	{
		case 1:
			m_status_page->start();
			break;
		default:
			break;
	}
}

